package com.jblog.common.page;

import java.io.Serializable;
import java.util.List;

import com.jblog.common.page.common.PageType;

public class Pagination extends SimplePage implements Serializable, Pageable{

    private static final long serialVersionUID = 1L;
    
    private List<?> datas;

    public Pagination(Integer pageNo, Integer pageSize, Long totalCount) {
        super(pageNo, pageSize, totalCount);
    }
    public Pagination(Integer pageNo, Integer pageSize, Long totalCount, PageType pageType) {
        super(pageNo, pageSize, totalCount, pageType);
    }
    
    public Pagination(Integer pageNo, Integer pageSize, Long totalCount,Integer step, PageType pageType) {
        super(pageNo, pageSize, totalCount, step, pageType);
    }


    public Integer getFirstResult() {
        return (pageNo - 1) * pageSize;
    }
    
    /**
     * at present for MyBatis&MySql's limit
     * <p>
     * if for Hibernate, you should change return value
     */
    public Integer getMaxResult() {
        return pageNo;
        //for Hibernate
        //return pageNo * pageSize > totalCount ? totalCount : pageNo * pageSize;
    }

    public List<?> getDatas() {
        return datas;
    }

    public void setDatas(List<?> datas) {
        this.datas = datas;
    }
}
